Repository navigation
feat(Tensors): Tensor, Species.pure and the group action Species.tensorRep - #2084
pariandrea wants to merge 6 commits into
Conversation
…nd PiTensorProduct.contrPairs Co-authored-by: Claude Opus 5.5 <no-reply+claude-opus-5-5@anthropic.com>
|
Thank you for this pull-request (PR). If this is your first PR, welcome to the community! While you wait for a review, note that you can review PRs too; reviewing is not restricted to maintainers. Our review guidelines explain what to look for. Over time, contributions such as reviews, maintenance and documentation are recorded on contributions.physlib.io. Three main points:
|
There was a problem hiding this comment.
I think we have some other results on PiTensorProduct in ./Mathematics, maybe these should be combined with this file.
There was a problem hiding this comment.
I couldn't find other PiTensorProduct results under ./Mathematics on master.
|
|
||
| A tensor with several indices lies in the tensor product `⨂[R] i, M i` of a family of spaces, one | ||
| space `M i` for each index `i`. Here `R` is the scalars, `ℝ` or `ℂ` in physics, and any commutative | ||
| semiring in the results below, with a commutative ring in which dimension is well defined, such as a |
There was a problem hiding this comment.
commutative ring in which dimension
I'm not sure what this means here
There was a problem hiding this comment.
Agreed, that sentence was unclear. It referred to the hypothesis [StrongRankCondition R] on Module.finrank_piTensorProduct, which turned out not to be needed. Mathlib gives it for every nontrivial commutative ring, so the proof now starts with nontriviality R and the hypothesis is gone. The overview now says that the results hold over any commutative semiring, except the dimension, which needs a commutative ring.
|
|
||
| /-- An intertwining map sends an invariant vector to an invariant vector, | ||
| `ρ g v = v → σ g (φ v) = φ v`. -/ | ||
| lemma Representation.IntertwiningMap.map_invariant (φ : ρ.IntertwiningMap σ) {v : V} {g : G} |
There was a problem hiding this comment.
I don't think we need this as it is a simple rw
|
|
||
| /-- An intertwining map `φ` from the trivial representation on `k` picks out an invariant vector, | ||
| `φ 1`. The hypothesis `φ 1 = v` turns a formula for `φ 1` into the invariance of `v`. -/ | ||
| lemma Representation.IntertwiningMap.map_one_invariant |
There was a problem hiding this comment.
Likewise, don't think we need to add this
|
|
||
| /-- The tensor product of two equivalences of representations, `v ⊗ u ↦ φ v ⊗ ψ u`, Mathlib's | ||
| `TensorProduct.congr` with the actions `ρ ⊗ τ` and `σ ⊗ π`. -/ | ||
| noncomputable def Representation.Equiv.tensorCongr (φ : ρ.Equiv σ) (ψ : τ.Equiv π) : |
There was a problem hiding this comment.
Representation.Equiv.tprodCongr might be better
| /-- The tensors with colors `c : ι → Color K`, the space `⨂[k] i, S.V (c i)`. It is a `def`, not an | ||
| `abbrev`, so that goals show `Tensor S c` instead of the product. Mathlib's results on `⨂` apply to | ||
| it by unfolding, and its instances are copied from `⨂`. -/ | ||
| def _root_.Tensor (S : Species k G K basisIdx) {ι : Type} (c : ι → Color K) : Type := |
There was a problem hiding this comment.
Would move out of the name space
|
|
||
| /-- The action `Λ • T` of the group on tensors, `S.tensorRep c Λ T`, available under | ||
| `open scoped Tensor`, where it takes priority over Mathlib's scalar actions. -/ | ||
| noncomputable abbrev distribMulAction : DistribMulAction G (Tensor S c) := |
There was a problem hiding this comment.
Why not just make this an instance?
| scoped[Tensor] attribute [instance 1100] Tensor.Species.distribMulAction | ||
|
|
||
| /-- The scalar multiplication of `distribMulAction`, found before any scalar action of Mathlib. -/ | ||
| noncomputable abbrev smul : SMul G (Tensor S c) := distribMulAction.toSMul |
There was a problem hiding this comment.
Likewise, why not make this an instance?
| /-- The tensors with colors `c : ι → Color K`, the space `⨂[k] i, S.V (c i)`. It is a `def`, not an | ||
| `abbrev`, so that goals show `Tensor S c` instead of the product. Mathlib's results on `⨂` apply to | ||
| it by unfolding, and its instances are copied from `⨂`. -/ | ||
| def _root_.Tensor (S : Species k G K basisIdx) {ι : Type} (c : ι → Color K) : Type := |
There was a problem hiding this comment.
This might be a bit of a radical design decision, but we could think about whether we actually want to define Tensor, and instead just rely on something like the Tensorial instance on the old method. That way we would not have to prove things more then once.
There was a problem hiding this comment.
I tried this on a branch, rebuilding everything up to Tensorial without a Tensor type. It all works and no proof changes, but it only saves about ten lines. The new Tensorial already avoids the double proofs, since toTensor is now an equivalence of representations, so things like Lorentz.Vector get all the tensor results through it without re-proving anything (the class is in #2014). Keeping Tensor is mainly for readability, since signatures and goals show Tensor S c instead of the full ⨂. So I'd keep it for now.
|
awaiting-author |
…othesis Drop [StrongRankCondition R]. Over a nontrivial commutative ring Mathlib provides it, and over the zero ring both sides are 1. State the hypotheses on R plainly in the overview. Co-authored-by: Claude Opus 5.5 <no-reply+claude-opus-5-5@anthropic.com>
…dCongr Also tensorCongr_tmul to tprodCongr_tmul, after Representation.tprod. Co-authored-by: Claude Opus 5.5 <no-reply+claude-opus-5-5@anthropic.com>
…e_invariant Both are one rewrite with Mathlib's IntertwiningMap.isIntertwining and have no use in this PR. Co-authored-by: Claude Opus 5.5 <no-reply+claude-opus-5-5@anthropic.com>
Define Tensor and its AddCommGroup and Module instances before namespace Tensor, instead of as _root_.Tensor inside it. Co-authored-by: Claude Opus 5.5 <no-reply+claude-opus-5-5@anthropic.com>
… namespace Tensor Tensor.distribMulAction, Tensor.smul, Tensor.smulCommClass and Tensor.smulCommClass' are one-line scoped instances, active under open scoped Tensor. They replace the abbrevs and lemmas in Tensor.Species made instances by scoped[Tensor] attribute. Co-authored-by: Claude Opus 5.5 <no-reply+claude-opus-5-5@anthropic.com>
Second piece of the stack for #2014, after #2049. It introduces the tensors of a species and the
group action on them.
This code was written with AI assistance, specifically Claude and ChatGPT.
Design
c : ι → Color Kare Mathlib's⨂[k] i, V (c i), for any index typeι, not onlyFin n.Tensor S cis adef, so its typekeeps the species and the colors. It sits at the root, so its lemmas live in the library
namespace
Tensor, asTensorProductdoes in Mathlib.tensors
S.pure f = ⨂ₜ i, f i(ext_pure, anextlemma), and a property of all tensors followsfrom the pure case (
inductionOn_pure). Maps that commute with the group are built from a checkon pure tensors (
equivOfPure,map_smul_of_pure).Λ • (u ⊗ α) = Λu ⊗ (Λ⁻¹)ᵀα(smul_pure). Mathlib has the representation on the tensor productof two representations, but not of a family.
Representation.piTprod, added in ForMathlib, isthat representation on
⨂ i, M i.tensorRepis the action as aRepresentation, and mapsthat commute with it are Mathlib's
Representation.EquivandRepresentation.IntertwiningMap,so the invariance of a tensor built from invariant pieces follows from
map_invariant.⨂as maps of representations. ForMathlib proves that applying maps atthe factors (
PiTensorProduct.map,congr), reordering (reindex), joining two families(
tmulEquivDep), a single factor (subsingletonEquiv) and the contraction of pairs of factors(
contrPairs, new) commute withpiTprod. Later pieces build reindexing, products andcontraction of tensors on these.
Λ • Tis scoped. The instancedistribMulActionis scoped toTensor, soΛ • Tneedsopen scoped Tensor. It has high priority there, since Mathlib gives some groups,such as
Circleandℂˣ, a scalar action on everyℂ-module.T^μ_νρare coordinates inBasis.piTensorProduct(tensorBasis). The matrix ofPiTensorProduct.mapis the Kroneckerproduct of the matrices at the factors (
toMatrix_map_apply, Mathlib has two factors), sotensorBasis_repr_smulgives the textbook law(ΛT)^μ_νρ = Λ^μ_σ (Λ⁻¹)^τ_ν (Λ⁻¹)^λ_ρ T^σ_τλ.mapIndicesapplies a linear map at every index, through Mathlib'sPiTensorProduct.map, andmapAtapplies one at a single index, with the identity elsewhere.Mathlib's
PiTensorProductandRepresentationinForMathlib, and the tensor lemmas are itstransports. The two ForMathlib files come whole with this PR, so some of their results are first
used in later pieces of the stack.
Added
Physlib/Mathematics/ForMathlib/PiTensorProduct.leanPiTensorProduct.toMatrix_map_apply: the matrix ofPiTensorProduct.mapis the Kroneckerproduct of the matrices.
Module.finrank_piTensorProduct: the dimension of⨂ i, M iis the product of the dimensions.PiTensorProduct.map_eq_id_of_isEmpty: with no factors, everyPiTensorProduct.mapis theidentity.
PiTensorProduct.contrPairs,PiTensorProduct.contrPairs_tprod: the contraction of the pairsof factors chosen by
κ ⊕ (J ⊕ J)with a family of pairings.Physlib/Mathematics/ForMathlib/Representation.leanRepresentation.IntertwiningMap.map_invariant: an intertwining map sends invariant vectors toinvariant vectors.
Representation.IntertwiningMap.map_one_invariant: an intertwining map from the trivialrepresentation picks out an invariant vector.
Representation.Equiv.tensorCongr,Representation.Equiv.tensorCongr_tmul: the tensor productof two equivalences of representations.
Representation.piTprod,Representation.piTprod_apply,Representation.piTprod_tprod: therepresentation on
⨂ i, M i.Representation.IsIntertwiningMap.piTprodMap,Representation.Equiv.piTprodCongr,Representation.Equiv.piTprodCongr_tprod:PiTensorProduct.mapof intertwining maps.Representation.Equiv.piTprodReindex,Representation.Equiv.piTprodReindex_tprod: reindexingthe factors along an equivalence of index types.
Representation.Equiv.piTprodSum,Representation.Equiv.piTprodSum_tmul: the tensor productof the two halves of a family indexed by
ι₁ ⊕ ι₂.Representation.Equiv.piTprodOfSubsingleton: a representation as the tensor product of afamily over a subsingleton index type.
Representation.map_piTprod_of_tprod: a semilinear map that commutes withpiTprodon puretensors commutes with it everywhere.
Representation.IsIntertwiningMap.contrPairs: the contraction of pairs of factors is anintertwining map when the pairings are invariant.
Physlib/Mathematics/Tensors/Tensor.leanTensor: the tensors with colorsc, with its additive group and module instances.Species.pure: the pure tensor of a family of vectors.Species.inductionOn_pure,Species.ext_pure: induction and extensionality through puretensors.
Species.tensorRep: the action as a Mathlib representation.Species.distribMulAction,Species.smul,Species.smulCommClass,Species.smulCommClass':the scoped instances for
Λ • T.Species.smul_pure: the action index by index.Species.intertwiningMap_smul,Species.equiv_smul: maps of representations commute with theaction.
Species.map_smul_of_pure: a map that commutes with the action on pure tensors commutes withit everywhere.
Species.equivOfPure,Species.equivOfPure_apply: an equivalence of representations from acheck on pure tensors.
Species.equiv_ext_pure: extensionality for equivalences of representations.Species.smul_eq_self_of_isEmpty: a tensor with no indices is invariant.Species.tensorBasis,Species.tensorBasis_apply,Species.tensorBasis_repr_pure: the basisof tensors and the components of a pure tensor.
Module.Finiteinstance,Species.finrank_tensor: the dimension of tensors.Species.tensorBasis_repr_smul: the components ofΛ • T.Species.mapIndices,Species.mapIndices_pure,Species.mapIndices_comp,Species.mapIndices_mapIndices,Species.mapIndices_id,Species.mapIndices_id_apply,Species.mapIndices_smul: a linear map at every index.Species.congrIndices,Species.congrIndices_pure: an equivalence of representations at everyindex.
Species.indexMapsAt,Species.indexMapsAt_apply_self,Species.indexMapsAt_apply_ne,Species.eq_indexMapsAt,Species.indexMapsAt_rep: a linear map at one index and the identityat the others.
Species.mapAt,Species.mapAt_pure,Species.mapAt_comp,Species.mapAt_id,Species.tensorBasis_repr_mapAt: applying it.Species.congrAt,Species.congrAt_eq_mapAt,Species.congrAt_symm: the same for anequivalence of representations, as an equivalence of representations.
Reviewer map
Tensor.lean, for the design.Tensor.lean§A (tensors and pure tensors) and §B (the group action). This is where the designlives.
ForMathlib/Representation.lean, for the gap in Mathlib, then its §C(
piTprodand the maps that commute with it).ForMathlib/PiTensorProduct.lean: the Kronecker product, the dimension, andcontrPairsonthe arrangement
κ ⊕ (J ⊕ J).Tensor.lean§C (the basis and components).Tensor.lean§D (maps at the indices), which later pieces use for lowering at one index.